from data import *
import pyglet
from pyglet.gl import *
class Component(object):
	def __init__(self, parent=None, angle=0.0, distance=0.0, rotation=0.0, mass=1, image='thruster1'):
		super(Component, self).__init__()
		self.parent = parent
		self.angle=angle; self.distance=distance; self.rotation=rotation-angle
		self.img = assets.images[image]
		self.mass = mass
	def draw(self):	
		pass
	def act(self):
		pass

class Thruster(Component):
	def __init__(self, parent=None, angle=0.0, distance=0.0, rotation=0.0, mass=1.0, thrustForce = 1000, image='thruster1'):
		super(Thruster, self).__init__(parent, angle, distance, rotation, mass, image)
		self.thrustForce = thrustForce
	def draw(self):	
		glPushMatrix()
		glRotatef(self.angle, 0, 0, 0.1)
		glTranslatef(0,self.distance,0)
		glRotatef(self.rotation, 0, 0, 0.1)
		self.img.blit(0,0)
		glPopMatrix()
	def act(self):
		self.parent.applyTorque(F=self.thrustForce, r=self.distance, theta=self.rotation)
		self.parent.applyForce(F=self.thrustForce, r=self.distance, theta=self.rotation+self.angle)